home *** CD-ROM | disk | FTP | other *** search
/ Total Web Page (Professional Suite) / Total Web Page 99.iso / CGI / DOWNLOAD.CGI-S=TEXTCOUNTER&C=TXT&F=README < prev    next >
Text File  |  1996-06-03  |  12KB  |  255 lines

  1. ##############################################################################
  2. # TextCounter (Requires Server Side Includes) Version 1.2                 #
  3. # Created by Matt Wright    mattw@worldwidemart.com                 #
  4. # Created on: 3/14/96        Last Modified on: 5/10/96                #
  5. # Scripts Found at:             http://www.worldwidemart.com/scripts/        #
  6. ##############################################################################
  7. # If you run into any problems while trying to configure this script, help   #
  8. # is available.  The steps you should take to get the fastest results, are:  #
  9. #       1) Read this file thoroughly                                         #
  10. #       2) Consult the Matt's Script Archive Frequently Asked Questions:     #
  11. #               http://www.worldwidemart.com/scripts/faq/                    #
  12. #       3) If you are still having difficulty installing this script, send   #
  13. #          e-mail to: scripts-help@tahoenet.com                              #
  14. #          Include any error messages you are receiving and as much detail   #
  15. #          as you can so we can spot your problem.  Also include the variable#
  16. #          configuration block that is located at the top of the script.     #
  17. #                                                                            #
  18. # Hopefully we will be able to help you solve your problems.  Thank you.     #
  19. ##############################################################################
  20. # COPYRIGHT NOTICE                                                           #
  21. # Copyright 1996 Matthew M. Wright  All Rights Reserved.                     #
  22. #                                                                            #
  23. # TextCounter may be used and modified free of charge by anyone so long as   #
  24. # this copyright notice and the comments above remain intact.  By using this #
  25. # code you agree to indemnify Matthew M. Wright from any liability that      # 
  26. # might arise from it's use.                                                 #
  27. #                                                                            #
  28. # Selling the code for this program without prior written consent is         #
  29. # expressly forbidden.  In other words, please ask first before you try and  #
  30. # make money off of my program.                                              #
  31. #                                                                            #
  32. # Obtain permission before redistributing this software over the Internet or #
  33. # in any other medium.  In all cases copyright and header must remain intact.#
  34. ##############################################################################
  35.  
  36. TextCounter 1.2 is a simple program which allows you to include 
  37. a text counter on any page.  You can also include the date since it began 
  38. counting, a link to a help page, etc...  This program was designed for 
  39. anyone to use, from a user who just wants a text counter on his or her 
  40. home page to a system administrator who wants to make it easy for anyone 
  41. on their server to use the count program.  Multiple counters can be set 
  42. up, with the need for only one script to manage them all.  You can 
  43. specify what hosts are allowed to access this program, and can even allow 
  44. certain directories or exclude certain directories from being able to use 
  45. this script.  Details on how to install and use this script are available 
  46. below.
  47.  
  48. This package should have come with 2 files:
  49.     1) README     - This file.  Installation Instructions, 
  50.               Disclaimer, Copyright
  51.     2) counter.pl   - The CGI/Perl program which does all of the work.
  52.  
  53. Installation:
  54. =============
  55.  
  56. counter.pl
  57. ------------
  58.  
  59. The first thing you will need to do when you get ahold of this script is 
  60. make sure that the first line of the script correctly points to the Perl 
  61. executable on your system.  If you don't know where this is for sure, use 
  62. the command:
  63.  
  64. which perl
  65. or
  66. whereis perl
  67.  
  68. from your Unix shell.
  69.  
  70. There are also several Variables and Options you will need to configure.  
  71. The instructions below provide examples and instructions of how to do so.
  72.  
  73. VARIABLE CONFIGURATION:
  74.     $data_dir = "/path/to/a/data/directory/";
  75.         The $data_dir variable should specify the path to the 
  76.         directory under which all of th data files will be stored.
  77.         This path must end with a '/' and it NEEDS to be writable by 
  78.         your web server.  This means that you most likely will need 
  79.         to chmod this directory 777.  You can do this by executing:
  80.  
  81.             chmod 777 /path/to/a/data/directory/
  82.  
  83.         It is suggested that you make this directory a brand new 
  84.         directory for the sole purpose of holding the data files.  A 
  85.         new data file will be created for each page you add your text
  86.         counter to.  You may think that this is not the best way to 
  87.         do this, but it is not all bad, and is beneficial in some 
  88.         ways:
  89.  
  90.             1) If you use this system wide, it is likely that 
  91.                many pages will load at the same time, meaning 
  92.                 this script would have to try and edit the main 
  93.                file if it was all included in one database.  
  94.                This file can lead to slow downs (if I locked the
  95.                file each time it was called) or it could lead to 
  96.                mangled data if I didn't.  That is one reason I 
  97.                chose to use separate files.
  98.             2) The files created for the data are EXTREMELY 
  99.                small, taking up between 15 and 30 bytes (yes, 
  100.                you heard correctly, bytes).
  101.             3) Access time is faster as I know exactly what 
  102.                file to open, rather than flipping through lines 
  103.                of a database if it was all in one file.
  104.             (BTW, this explanation was more for people who 
  105.             may have questioned why I chose to do it this way.  
  106.             Most of you could care less about these last 3 points)
  107.               :-)
  108.  
  109.     @valid_uri = ("/");
  110.         The @valid_uri array allows you to allow this script to 
  111.         be used only under a certain directory of your server.  Say 
  112.         your username is fred and you are on a server called 
  113.         host.com, therefore all of your pages reside under: 
  114.         http://www.host.com/~fred/.  You only want those pages under
  115.         that directory to be able to use this program, so you set the 
  116.         @valid_uri variable to ("/~fred"); or you can allow you and 
  117.         your friend joe to use it by setting the @valid_uri variable
  118.         to: ("/~fred","/~joe");  Or if you are a sysadmin who wants 
  119.         to allow everyone to use this script, simply set this array 
  120.         to ("/"); as I have shown above.
  121.  
  122.     @invalid_uri = ("");
  123.         Most likely you will just comment this line out if you do 
  124.         not wish to block access to a certain part of your server.
  125.         But take the example of fred above.  He decides to be real 
  126.         cool and open this program up to anyone on the server by 
  127.         setting @valid_uri = ("/");  His arch enemy bob is also on 
  128.         the server though, and fred despises him so much that he 
  129.         wants to block access to this guy, cause bob is such a jerk.
  130.         So fred sets his @invalid_uri = ("/~bob"); and bob can't use 
  131.         his counter. MU HA HA HA.  I'm sure there are other cool uses
  132.         for this too.  Like if you sell virtual domains and want to 
  133.         charge people before they can use your counter script, you 
  134.         put their URI in here until they pay or something.  I dunno. 
  135.         The story was fun to write, and that's all that matters. :-)
  136.  
  137. OPTION SETTINGS:
  138.     $show_link = "http://www.worldwidemart.com/scripts/";
  139.         If you put a URL into this option, then the actual number 
  140.         returned by the TextCounter script will be linked to this 
  141.         URL.  This is useful if you want to link to my site 
  142.         (PLEASE?!) or link to a help page explaining how the user 
  143.         on your system can set up their own text counter.  or if 
  144.         you just want to have a pointless link on your number.  
  145.         Setting this to a null value like "" or 0 will take out the
  146.         link.
  147.  
  148.     $auto_create = "1";
  149.         Suggested value here is 1, or else you will have to 
  150.         create data files by hand.  This allows users who reside 
  151.         under the @valid_uri array to create a new counter for their 
  152.         page simply by putting the Server Side Include reference into
  153.         their page.  Otherwise the maintainer will have to create a 
  154.         data file which looks like:
  155.  
  156.             January 1, 2000||0
  157.  
  158.         Obviously putting the correct date into the script and 
  159.         changing 0 to whatever you want to start the number at.  
  160.         This file MUST be writable by the web server meaning you 
  161.         need to chmod it 777.  This means other users on your 
  162.         system can write to it too, which is another reason to allow 
  163.         auto-create.  Auto-Create will leave it chmoded so only the 
  164.         web server can write to it.
  165.  
  166.     $show_date = "1";
  167.         If this variable is on, then the date on which you began 
  168.         the count will appear with your actual count number.  It 
  169.         will look like: 
  170.  
  171.             [Count] hits since [Date]
  172.  
  173.         If this is turned off, you allow users more control over 
  174.         their text and it will simply print:
  175.  
  176.             [Count]
  177.  
  178.         The user can then supply the date if they wish.
  179.  
  180.     $lock_sec = "3";
  181.                 The $lock_sec variable defines how long the program will
  182.                 wait for the lock file to be cleared out, before going on and
  183.                 overwriting the current lock file.  Often times, the
  184.                 count file would get overwritten in the older versions
  185.                 because there were no locks on the files, and when two
  186.                 users accessed at once, it messed things up.
  187.  
  188.                 There are now built in lock routines, but if a user stops
  189.                 the process or your machine gets turned off or re-booted 
  190.                 while the lock file is still in the directory, that lock 
  191.         file needs to get removed somehow.  The $lock_sec variable
  192.                 tells the script how long it should wait before deciding
  193.                 that the lock file is not valid.
  194.  
  195.                 Most of the time the script should not take longer than a
  196.         second to execute, but to be safe I set the default to 
  197.         about 3 seconds.  You can vary this depending on whether 
  198.         you think your system will operate much faster or slower.
  199.  
  200.     $pad_size = "5";
  201.         You will notice if you have seen many other counters on 
  202.         the web, graphical or text-based, that they are often 
  203.         padded with zeros at the front to form a number like: 
  204.         0000154.  This is achieved by adding 0's to the front of 
  205.         the current count.  In Version 1.2, you can specify how many
  206.         digits long you want your number to be, so in the example 
  207.         above you would set $pad_size = "7";
  208.  
  209.         If you do not want your number padded and wish for the 
  210.         above example to appear as 154 in your page, then set 
  211.         $pad_size = "1";
  212.  
  213. ______________________________________________________________________________
  214.  
  215. HOW TO CALL THIS SCRIPT FROM YOUR PAGE?
  216.  
  217. Calling this program is really very simple.  As I have mentioned before, 
  218. you will need Server Side Includes turned on on your server before you 
  219. can use this program.  Talk to your system administrator or visit my 
  220. Frequently Asked Questions section for more information on server side 
  221. includes.  If you know they are turned on, or want to try and find out, 
  222. put the following code into your HTML document:
  223.  
  224. <!--#exec cgi="/virtual/path/to/counter.pl"-->
  225.  
  226. So, if I have my counter.pl (or counter.cgi if I have to rename it for 
  227. my server) program located at 
  228. http://www.worldwidemart.com/scripts/demos/textcounter/counter.pl, then I 
  229. would put the following into any HTML document a wanted a count to appear in:
  230.  
  231. <!--#exec cgi="/scripts/demos/textcounter/counter.pl"-->
  232.  
  233. _____________________________________________________________________________
  234.  
  235. Well, that covers all of the options and variables, and I explained these 
  236. in such detail that hopefully I won't get swamped by help mail for this 
  237. script. :-D (Yah right!)  But please, before you ask for help, follow the 
  238. steps at the top of this document.  You probably won't get an answer from 
  239. myself or the help staff if your answer is in the Frequently Asked 
  240. Questions at my site.
  241. _____________________________________________________________________________
  242.  
  243. HISTORY:
  244. Version 1.0    - 03/14/96 -    * TextCounter Created and Released.
  245. Version 1.1    - 04/25/96 -    * @valid_referer array and checking 
  246.                   removed.  Because server side includes can 
  247.                   only be used locally, it is unnecessary.  
  248.                   Also, it was causing many counters to 
  249.                   incorrectly display error messages.
  250. Version 1.2    - 05/10/96 -    * File Locking Procedure added.
  251.                 * Options $lock_sec and $pad_size added.
  252. _____________________________________________________________________________
  253. Matt Wright - mattw@worldwidemart.com - http://www.worldwidemart.com/scripts/
  254.  
  255.